Option Explicit

' 表物理名所在的行号，默认值=1
Private Const TABLE_PHY_NAME_ROW_NO As Integer = 1
' table 物理名标题列的标题内容
Private Const TABLE_PHY_NAME_TITLE_CONTENT As String = "tableName"
' 列逻辑名所在的行号(默认值=2)
Private Const COLUMN_LOGIC_NAME_ROW_NO As Integer = 2
' 列物理名所在的行号(默认值=3)
Private Const COLUMN_PHY_NAME_ROW_NO As Integer = 3
' 列类型所在的行号(默认值=4)
Private Const COLUMN_TYPE_ROW_NO As Integer = 4
' 列数据长度所在的行号(默认值=5)
Private Const COLUMN_SIZE_ROW_NO As Integer = 5
' 数据起始行所在的行号(默认值=7)
Private Const DATA_START_ROW_NO As Integer = 7
' table 定义列的列号(默认值=3)
Private Const DEFINE_TITLE_COL_NO As Integer = 3
' 需要生成的数据数量(默认值=5)
Private Const DEFAULT_DATA_COUNT As Integer = 5

Public Sub main()
    Dim wb As Workbook
    Set wb = ActiveWorkbook

    Dim form As VBComponent
    Set form = wb.VBProject.VBComponents.Item("createTableDataForm")

    ' ==================================================
    ' 1. 设置 form 的属性
    ' ==================================================
    With form
        .Properties("Height") = 300
        .Properties("Width") = 550
        .Properties("Caption") = "create table data"
    End With

    Dim ctrs As Controls
    Set ctrs = form.Designer.Controls

    ' ==================================================
    ' 2. 第一行
    ' ==================================================
    ' 1. 设置: table 物理名所在的行号(默认值=1)
    '    标题
    UtilsControl.createLabel ctrs, "tablePhyNameRowNoLabel", _
        18, 114, 42, 18, caption:="Table Phy Name RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "tablePhyNameRowNoBox", _
        24, 36, 162, 12, _
        fontSize:=12, text:=TABLE_PHY_NAME_ROW_NO, value:=TABLE_PHY_NAME_ROW_NO, tabIndex:=1

    ' 2. 设置: table 物理名标题列的标题内容(默认值=tableName)
    '    标题
    UtilsControl.createLabel ctrs, "tablePhyNameTitleContentLabel", _
        18, 150, 210, 18, caption:="Table Phy Name Title Content", fontSize:=10

    '    输入框
    UtilsControl.createTextBox ctrs, "tablePhyNameTitleContentBox", _
        24, 150, 372, 12, _
        fontSize:=12, text:=TABLE_PHY_NAME_TITLE_CONTENT, value:=TABLE_PHY_NAME_TITLE_CONTENT, tabIndex:=2

    ' ==================================================
    ' 3. 第二行
    ' ==================================================
    ' 1. 设置: 列逻辑名所在的行号(默认值=2)
    '    标题
    UtilsControl.createLabel ctrs, "columnLogicNameRowNoLabel", _
        18, 132, 24, 48, caption:="Column Logic Name RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnLogicNameRowNoBox", _
        24, 36, 162, 42, _
        fontSize:=12, text:=COLUMN_LOGIC_NAME_ROW_NO, value:=COLUMN_LOGIC_NAME_ROW_NO, tabIndex:=3

    ' 2. 设置: 列物理名所在的行号(默认值=3)
    '    标题
    UtilsControl.createLabel ctrs, "columnPhyNameRowNoLabel", _
        18, 126, 246, 48, caption:="Column Phy Name RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnPhyNameRowNoBox", _
        24, 36, 372, 42, _
        fontSize:=12, text:=COLUMN_PHY_NAME_ROW_NO, value:=COLUMN_PHY_NAME_ROW_NO, tabIndex:=4

    ' ==================================================
    ' 4. 第三行
    ' ==================================================
    ' 1. 设置: 列类型所在的行号(默认值=4)
    '    标题
    UtilsControl.createLabel ctrs, "columnTypeRowNoLabel", _
        18, 102, 54, 78, caption:="Column Type RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnTypeRowNoBox", _
        24, 36, 162, 72, _
        fontSize:=12, text:=COLUMN_TYPE_ROW_NO, value:=COLUMN_TYPE_ROW_NO, tabIndex:=5

    ' 2. 设置: 列数据长度所在的行号(默认值=5)
    '    标题
    UtilsControl.createLabel ctrs, "columnSizeRowNoLabel", _
        18, 102, 264, 78, caption:="Column Size RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnSizeRowNoBox", _
        24, 36, 372, 72, _
        fontSize:=12, text:=COLUMN_SIZE_ROW_NO, value:=COLUMN_SIZE_ROW_NO, tabIndex:=6

    ' ==================================================
    ' 5. 第四行
    ' ==================================================
    ' 1. 设置: 数据起始行所在的行号(默认值=7)
    '    标题
    UtilsControl.createLabel ctrs, "dataStartRowNoLabel", _
        12, 90, 60, 108, caption:="Data Start RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "dataStartRowNoBox", _
        24, 36, 162, 102, _
        fontSize:=12, text:=DATA_START_ROW_NO, value:=DATA_START_ROW_NO, tabIndex:=7

    ' 2. 设置: table 定义标题列的列号 (3 = C列)
    '    标题
    UtilsControl.createLabel ctrs, "defineTitleColNoLabel", _
        12, 102, 264, 108, caption:="Define Title ColNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "defineTitleColNoBox", _
        24, 36, 372, 102, _
        fontSize:=12, text:=DEFINE_TITLE_COL_NO, value:=DEFINE_TITLE_COL_NO, tabIndex:=8

    ' ==================================================
    ' 6. 第五行
    ' ==================================================
    ' 1. range
    '    标题
    UtilsControl.createLabel ctrs, "rangeLabel", _
        18, 42, 18, 144, caption:="Range", fontSize:=12

    '    输入框
    UtilsControl.createRefEdit ctrs, "rangeBox", _
        24, 420, 60, 138, _
        fontSize:=12, tabIndex:=9

    ' ==================================================
    ' 7. 第六行
    ' ==================================================
    ' 1. 设置: 需要生成的数据的行数
    '    标题
    UtilsControl.createLabel ctrs, "dataCountLabel", _
        12, 54, 96, 186, caption:="dataCount", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "dataCountBox", _
        24, 120, 156, 180, _
        fontSize:=12, text:=DEFAULT_DATA_COUNT, value:=DEFAULT_DATA_COUNT, tabIndex:=10

    ' ==================================================
    ' 7. 第六行
    ' ==================================================
    ' 1. 为范围内的 table 生成数据
    UtilsControl.createButton ctrs, "createDataForRangeBtn", _
        30, 108, 204, 216, _
        caption:="createDataForRange", fontSize:=10, tabIndex:=11

    ' 2. 为整个 sheet 的 table 生成数据
    UtilsControl.createButton ctrs, "createDataForSheetBtn", _
        30, 108, 324, 216, _
        caption:="createDataForSheet", fontSize:=10, tabIndex:=12

End Sub
